<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="Visible"
      width="70%"
      :close-on-click-modal="false"
      @close="cancel"
    >
      <div class="midContant clearfix">
        <MyTable
        :tableColumn="tableColumn"
        :tableData="tableData"
        :isOrder="false"
        >
          <template v-slot:content="scope">
              <span class="btnCLass" v-if="scope.config.templateType=='textBtn_del'&&scope.row.sync_flag==0" @click="del(scope.row)">{{$t('common.del')}}</span>
              <span v-else>{{ scope.row[scope.config.prop] }}</span>
            </template>
        </MyTable>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button  @click="cancel" size="small">{{$t('common.cancel')}}</el-button>
      </span>
      
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
  },
  data() {
    return {
      Visible: false,
      title:'',
      package_sn:'',
      tableColumn:[
        {
          label: "",
          prop: "table_code",
          width: 40,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.trajectory_time'),
          prop: "track_at",
          width: 220,
        },
        {
          checked: true,
          label: this.$t('ExpressCargoManagementLang.trajectory_text'),
          prop: "desc_current",
        },
      ],
      tableData:[],
    };
  },
  created() {
    
  },
  mounted() {
  },
  deactivated(){
    
  },
  watch: {
  },
  methods: {
    init(data,name) {
      if(name=='删除'){
        this.title=this.$t('ExpressCargoManagementLang.trajectory_del')
        this.tableColumn=[
          {
            label: "",
            prop: "table_code",
            width: 40,
          },
          {
            checked: true,
            label: this.$t('ExpressCargoManagementLang.trajectory_time'),
            prop: "track_at",
            width: 220,
          },
          {
            checked: true,
            label: this.$t('ExpressCargoManagementLang.trajectory_text'),
            prop: "desc_current",
          },
          {
            checked: true,
            label: this.$t('LineManagementLang.operation'),
            prop: "operation",
            width: 80,
            templateType:'textBtn_del'
          }
        ]
      }else{
        this.title=this.$t('ExpressCargoManagementLang.trajectory_query')
        this.tableColumn=[
          {
            label: "",
            prop: "table_code",
            width: 40,
          },
          {
            checked: true,
            label: this.$t('ExpressCargoManagementLang.trajectory_time'),
            prop: "track_at",
            width: 220,
          },
          {
            checked: true,
            label: this.$t('ExpressCargoManagementLang.trajectory_text'),
            prop: "desc_current",
          },
        ]
      }
      this.Visible = true;
      this.package_sn=data.package_sn
      this.getData();
    },
    //获取单条
    getData() {
      this.$get("getTrack", { package_sn: this.package_sn}).then((res) => {
        this.tableData = res.data;
      });
    },
    del(row){
      let params = new FormData();
      params.append("id", row.id);
      this.$postForm("delTrack", params).then((res) => {
        if(res.success){
          this.$message.success(res.msg);
          this.getData();
        }
      });
    },
    //取消修改
    cancel() {
      this.tableData=[]
      this.Visible = false;
    },
  },
};
</script>

<style scoped lang="less" >
  .midContant {
    border: 0;
    width: 100%;
    height: 500px;
  }
</style>